// api/topic.js
import { request } from "@/utils/request";




// 获取经书列表的参数接口
interface GetTopicListParams {
  keyword?: string;
  pageNum: number;
  pageSize: number;
}



export interface ResponseData<T> {
  code: number;
  row?: T;
  msg: string;
}

export const getActivityList = async (params: GetTopicListParams) => {
  try {
    const { keyword = '', pageNum, pageSize } = params;
    const response = await request.get('/scripture/activity/list', {
      data: {
        keyword,
        pageNum,
        pageSize: 5
      }
    });
    return response as any;
  } catch (error) {
    console.error('获取主题列表失败:', error);
    return {
      code: -1,
      msg: '网络请求失败',
      rows: [],
      total: 0
    };
  }
};


export const getActivityDetail = async (activityId: number) => {
  try {
    const response = await request.get('/scripture/activity', {
      data: { activityId }
    });

    if (response.code === 200 && response.data) {
      return response.data as any;
    }

    return null;
  } catch (error) {
    console.error('获取主题细节失败:', error);
    throw error;
  }
};


export const signUpActivity = async (data: any) => {
  try {
    const response = await request.post('/scripture/activity/signUpActivity', data);
    return response;
  } catch (error) {
    console.error('获取主题细节失败:', error);
    throw error;
  }
};

export const cancelSignUpActivity = async (data: any) => {
  try {
    const response = await request.post('/scripture/activity/cancelSignUpActivity', data);
    return response;
  } catch (error) {
    console.error('获取主题细节失败:', error);
    throw error;
  }
};




